package com.example.demo;


import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/message")
public class MessageWallController {
    private List<MessageWall> list = new ArrayList<>();

    @RequestMapping("/publish")
    public Boolean publish(@RequestBody MessageWall messageWall) {
        //参数校验
        if(!StringUtils.hasLength(messageWall.getFrom())
                || !StringUtils.hasLength(messageWall.getTo())
                || !StringUtils.hasLength(messageWall.getMessage())) {
            System.out.println("参数不规范!");
            return false;
        }
        list.add(messageWall);
        return true;
    }

    @RequestMapping("/getlist")
    public List<MessageWall> getlist() {
        return list;
    }
}
